#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll N=50009;
ll n,q[N],f[N];
struct Book{ll h,w;} books[N];
struct Line{ld k,b;} lines[N];
ld X(ll u,ll v){
    return -(ld)(lines[u].b-lines[v].b)/(lines[u].k-lines[v].k);
}
int main(){
    //freopen("books.in","r",stdin);
    //freopen("books.out","w",stdout);
    cin>>n;
    for(ll i=1;i<=n;i++) cin>>books[i].h>>books[i].w;
    lines[0]=(Line){books[1].w,0};
    q[1]=0;
    ll l=1,r=2;
    for(ll i=1;i<=n;i++){
        while(r-l>=2&&X(q[l],q[l+1])<books[i].h) l++;
        ll a=q[l];
        f[i]=f[a]+books[a+1].w*books[i].h;
        lines[i]=(Line){books[i+1].w,f[i]};
        while(r-l>=2&&X(i,q[r-1])<X(q[r-1],q[r-2])) r--;
        q[r++]=i;
    }
    cout<<f[n]<<endl;
    return 0;
}